﻿

Imports DirectX.Engine

Public Class Form1
    Private StopRendering As Boolean
    Private FPSCounter As Integer
    Public WithEvents dx As Core3D
    Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
        Dim appPath As String = My.Application.Info.DirectoryPath
        Try
            dx = New Core3D(Me, Me.Handle, appPath)

            dx.Add3DObject(New Room)
            dx.Add3DObject(New Water)
            dx.Add3DObject(New Fountain)

            dx.FpsStart()
            Timer1.Enabled = True

            Do While dx.Enabled And StopRendering = False

                dx.Update()
                dx.Render()

                Application.DoEvents()

            Loop

            dx.Dispose()

        Catch ex As Exception
            MsgBox("Errore " & ex.Message)
            If dx IsNot Nothing Then dx.Dispose()
        End Try
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        StopRendering = True
    End Sub


     
    Private Sub dx_MousePos(sender As Object, args As Core3D.ScanEventArgs) Handles dx.MousePos
        Return
        Dim e As Point
        e = args.args
        Label1.Text = e.X & " " & e.Y

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        dx.Dispose()
        End
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If dx Is Nothing Then Return

        FPSCounter += 1
        Label1.Text = "FPS: (" & FPSCounter & ")  " & dx.FpsGet.ToString
    End Sub
End Class
